package view;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;

/**
 * Klasse NotificationCellRenderer
 * 
 * @author Magnus Brieler
 */
public class NotificationCellRenderer implements ListCellRenderer {

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		model.Notification n = (model.Notification) value;

		TitledBorder border = BorderFactory.createTitledBorder(n.getType().getName());
		JLabel text = new JLabel();
		text.setBorder(border);
		Font f = new Font(Font.DIALOG, Font.PLAIN, 12);
		text.setFont(f);
		
		text.setText("<html><b>" + n.getFrom().getUserName()
				+ "</b>" + n.getType().getText()
				+ (!n.getType().getAdditional().equals("") ? "<b>" + ((model.Chatroom) n.getBonus())
						.getName() + "</b>" + n.getType().getAdditional() : ""));

		if (cellHasFocus || isSelected) {
			text.setForeground(Color.BLACK);
			border.setTitleColor(Color.BLUE);
		} else {
			text.setForeground(Color.DARK_GRAY);
			border.setTitleColor(Color.DARK_GRAY);
		}

		return text;
	}

}